package com.liang.controller;


import com.liang.pojo.Dutyzx;
import com.liang.empty.Result;
import com.liang.utils.DateUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;;
import java.util.List;
import com.liang.service.DutyzxService;
/**
 *@作者:lsk
 *Controller接口
 *@Date:2023/10/20
*/
@RestController
@RequestMapping("/DutyzxURL")
public class DutyzxController {


	@Autowired
	private DutyzxService dutyzxservice;


	/**
	根据Duty_id查询
	*/
	@GetMapping("/selectByDuty_id/{duty_id}")
	public Result selectByDuty_id(@PathVariable(value = "duty_id") Long duty_id){
		return Result.buildSuccess(dutyzxservice.selectByDuty_id(duty_id));
	}


	/**
	根据Duty_id更新
	*/
	@PostMapping("/updateByDuty_id")
	public Result updateByDuty_id(@RequestBody Dutyzx demo){
		return Result.buildSuccess(dutyzxservice.updateByDuty_id( demo));
	}



	/**
	根据Duty_id删除
	*/
	@GetMapping("/deleteByDuty_id/{duty_id}")
	public Result deleteByDuty_id(@PathVariable(value = "duty_id") Long duty_id){
		return Result.buildSuccess(dutyzxservice.deleteByDuty_id(duty_id));
	}





	/**
	 insert:(插入)
	*/
	@PostMapping("/insert")
	public Result insert(@RequestBody Dutyzx demo){
		demo.setCreate_time(DateUtils.getTodayDateTime());
		Result.buildSuccess(dutyzxservice.insert(demo));
		return Result.buildSuccess(demo);
	}



	/**
	 insertOrUpdate(插入或更新(根据主键或唯一索引更新，主键和唯一索引不会改变))
	*/
	@PostMapping("/insertOrUpdate")
	public Result insertOrUpdate(@RequestBody Dutyzx demo){
		demo.setUpdate_time(DateUtils.getTodayDateTime());
		return Result.buildSuccess(dutyzxservice.insertOrUpdate(demo));
	}



	/**
	 insertBath:(批量插入)
	*/
	@PostMapping("/insertBatch")
	public Result insertBatch(@RequestBody List<Dutyzx> list){
		return Result.buildSuccess(dutyzxservice.insertBatch(list));
	}



	/**
	 insertOrUpdateBatch:(批量插入或更新)
	*/
	@PostMapping("/insertOrUpdateBatch")
	public Result insertOrUpdateBatch(@RequestBody List<Dutyzx> list){
		return Result.buildSuccess(dutyzxservice.insertOrUpdateBatch(list));
	}



	/**
	 selectList:(根据参数查询集合)
	*/
	@PostMapping("/selectList")
	public Result selectList(@RequestBody Map<String,Object> param){

		return Result.buildSuccess(dutyzxservice.selectList(param),dutyzxservice.selectCount(param));
	}



	/**
	 selectCount:(根据集合查询数量)
	*/
	@PostMapping("/selectCount")
	public Result selectCount(@RequestBody Map<String,Object> param){
		return Result.buildSuccess(dutyzxservice.selectCount(param));
	}


	/**
	 * 查询一个军队的职务,并查出是否有人担当
	 */
	@PostMapping("/selectArmysDutyxio")
	public Result selectArmysDutyxio(@RequestBody Map<String,Object> param){
		return Result.buildMessage(dutyzxservice.selectArmysDutyxio(param),"查询成功",200);
	}




	/**
	 * 查询一个人的职务
	 */
	@PostMapping("/selectoneUserDuty")
	public Result selectoneUserDuty(@RequestBody Map<String,Object> param){
		return Result.buildMessage(dutyzxservice.selectoneUserDuty(param),"查询成功",200);
	}





}